function [multi_ugc] = calculate_PVmultiplier(steps,ss,G,M,nvar,nexog)

% -------------------------------------------------------------------------
% Call index for endogenous variables
% -------------------------------------------------------------------------
variables;

% -------------------------------------------------------------------------
% Obtain Impulse Responses
% -------------------------------------------------------------------------
M   = M(:,nvar-nexog+1:end);
imf = zeros(nvar,nexog,steps);	

imf(:,:,1) = M;
for t = 2:steps
   imf(:,:,t) = G*imf(:,:,t-1);
end

imf = imf(:,:,1:steps);
%eliminate very small responses
for i = 1:nvar
    for j = 1:nexog
       for k = 1:steps
           if abs(imf(i,j,k))<10^-10
               imf(i,j,k) = 0;
           end
       end
    end
end

% -------------------------------------------------------------------------
% Compute Multipliers 
% -------------------------------------------------------------------------
r = ss(1); gc= ss(2); c=ss(3); y=ss(4); inv=ss(5); 

%====================================
%===== Govt consumption shock =======
%====================================
rtemp_ugc(:,1) = r*(1+0.01*imf(Nr,1,:)); 
GCtemp_ugc(:,1) = gc*(0.01*imf(Ngc,1,:));
Ctemp_ugc(:,1) = c*(0.01*imf(Nc,1,:));
Ytemp_ugc(:,1) = y*0.01*(imf(Ny,1,:));
Itemp_ugc(:,1) = inv*0.01*(imf(Ni,1,:));

%Construct discount factor
disc(1,1) = 1;
for i =2:steps
    disc(i,1) = disc(i-1,1)*rtemp_ugc(i,1);
end

%convert imuplse responses in goods units to PV
for i=1:steps
    discC_ugc(i,1) = Ctemp_ugc(i,1)/disc(i,1);
    discI_ugc(i,1) = Itemp_ugc(i,1)/disc(i,1);
    discY_ugc(i,1) = Ytemp_ugc(i,1)/disc(i,1);
    discGC_ugc(i,1) = GCtemp_ugc(i,1)/disc(i,1);
end
   
for i = 1:steps
    cumy_ugc = sum(discY_ugc(1:i,:))/sum(discGC_ugc(1:i,:));
    cumc_ugc = sum(discC_ugc(1:i,:))/sum(discGC_ugc(1:i,:));
    cumi_ugc = sum(discI_ugc(1:i,:))/sum(discGC_ugc(1:i,:));
    multi_ugc(i,:) = [cumy_ugc cumc_ugc cumi_ugc];
end

